package com.print.printusb

import android.app.Activity
import android.content.Context
import android.hardware.usb.UsbManager
import androidx.core.content.ContextCompat.getSystemService
import com.print.printusb.msprintsdk.PrintCmd
import com.print.printusb.msprintsdk.UsbDriver

class UsbDriverManager {
    var mUsbDriver: UsbDriver? = null
        get() {
            if (field == null) {
                throw Exception("pls initUsbDriverByActivity")
            }
            return field
        }

    fun initUsbDriverByActivity(activity: Activity) {
        mUsbDriver = UsbDriver(activity.getSystemService(Context.USB_SERVICE) as UsbManager?, activity)
    }

    /**
     * 3.2 清理缓存
     *     描述：清理缓存，清除之前设置的参数
     */
    fun setClean() {
        mUsbDriver?.write(PrintCmd.SetClean())
    }


}